package ui;

import io.DataAccess;

import javax.swing.JPanel;

/**
 * An abstract class that contains a reference to the parent window.
 * When constructed, it will add itself to the MainPage display stack
 * according to the needs of the subclass.
 * 
 * @author Aaron Chen
 * @version 3/14/2014
 */
@SuppressWarnings("serial")
public abstract class AbstractMainComponent extends JPanel implements MainComponent {

  /** The access to the application's database. */
  private DataAccess my_database;
  
  /** The main application window container. */
  private DisplayPanel my_parent;
  
  
  /**
   * Create the panel.
   * @param the_stack The main application window container's navigation panel.
   */
  public AbstractMainComponent(final DisplayPanel the_stack) {
    my_parent = the_stack;
    setFrameParameters();
    my_database = MainPage.getDatabase();
  }

  /**
   * Sets up the internal frame's properties.
   */
  protected void setFrameParameters() {
    setBackground(Standards.COLOR_BACKGROUND);
    setBorder(null);
    setFocusable(true);
  }
  
  /**
   * {@inheritDoc}
   */
  public DisplayPanel getDisplayStack() {
    return my_parent;
  }
  
  /**
   * {@inheritDoc}
   */
  public final DataAccess getDatabase() {
    return my_database;
  }
  
  /**
   * {@inheritDoc}
   */
  public abstract String getPanelLabel();

}
